package com.creative.accountsdk;

import android.text.TextUtils;

import org.json.JSONObject;

/**
 * Created by david on 15/11/25.
 */
public class UserInfor {
      public  long   uid;
      public  String birthday;
      public  String  nickname;
      public  Long    classId;
      public  int     state;
      public  String  avatar;
      public  String  updatedAt;
      public  Long    parentId;
      public  String  area;
      public  String  email;
      public  Long  createdAt;
      public  String  qrcode;
      public  int  gender;
      public  int  role;    //0未设置 1 家长 2孩子 3教师
      public  String  realname;
      public  Long  schoolId;
      public  String  mobile;

      public UserInfor setJsonToVo(JSONObject json){
            uid = json.optLong("uid");
            birthday = json.optString("birthday");
            if (!TextUtils.isEmpty(birthday) && birthday.equalsIgnoreCase("null")) {
                birthday = "";
            }
            nickname = json.optString("nickname");
            classId  =  json.optLong("classId");
            state = json.optInt("state");
            avatar = json.optString("avatar");
            updatedAt = json.optString("updatedAt");
            parentId = json.optLong("parentId");
            area = json.optString("area");
            email= json.optString("email");
            createdAt = json.optLong("createdAt");
          qrcode = json.optString("qrcode");
          gender = json.optInt("gender");
          role = json.optInt("role");

          realname = json.optString("realname");
          schoolId = json.optLong("schoolId");
          mobile = json.optString("mobile");
          return this;
      }

    public void setAvatar(String ava){
        avatar = ava;
    }
    public String getAvatar(){return avatar;}
}
